import { getDictInfo } from "@/api/sys/dictApi";
import { defineStore } from "pinia";

// 定义App的store
export const useAppStore = defineStore("app", {
  state: () => ({
    sysDict: {} as { [key: string]: SysDictDataEntity[] },
    sysConfig: {},
  }),
  getters: {},
  actions: {
    async initDict() {
      // 初始化字典
      const ids = ["sys_menu_type", "sys_status", "sys_sex"];
      const res = await getDictInfo(ids);
      if (res.code === 200) {
        this.sysDict = res.result;
      }
    },
    getDictByKey(key: string) {
      return this.sysDict[key];
    },
  },
});

export default useAppStore;
